package cn.game.tanke.manger;

import cn.game.tanke.panel.TankPanel;
import cn.game.tanke.role.Bullet;
import cn.game.tanke.role.Boom;

import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

public class BulletManager {
    private CopyOnWriteArrayList<Bullet> bullets;
    private TankPanel panel;
    private BoomManager boomManager;

    public BulletManager(TankPanel panel, BoomManager boomManager) {
        this.panel = panel;
        this.boomManager = boomManager;
        bullets = new CopyOnWriteArrayList<>();
    }

    public void addBullet(Bullet bullet) {
        bullets.add(bullet);
    }

    public void drawBullets(java.awt.Graphics graphics, javax.swing.JPanel jPanel) {
        for (Bullet bullet : bullets) {
            bullet.drawRole(graphics, jPanel);
        }
    }

    public void checkCollisions() {
        for (Bullet bullet : bullets) {
            bullet.checkCollision();
        }
    }

    public void stopAllBullets() {
        for (Bullet bullet : bullets) {
            bullet.stopMoving();
        }
    }
}